# -*- coding: utf-8 -*-

import datetime

class DateUtil:

    def __init__(self):
        self.data_list = ['0331', '0630', '0930', '1231']
        self.today = datetime.date.today()
        self.year = self.today.year

    def getLatestDate(self, num=0):
        if(num <= 0 or num > 5):
            return

        data_list = []
        while num > 0:
            for data in self.data_list:
                data_list.append(str(self.year) + data)
            num = num - 1
            self.year = self.year - 1

        return data_list

    def get_date(
            self,
            interval=0
    ) -> datetime.date:
        # print(0, interval)
        # print(1, self.today, type(self.today))
        # print(2, self.today + datetime.timedelta(interval))
        # print(3, type(self.today + datetime.timedelta(interval)))
        return self.today + datetime.timedelta(interval)

    def get_date_strftime(self, interval=0, strftime='%Y-%m-%d'):
        return self.get_date(interval).strftime(strftime)

    def cal_interval(self, cal_day):
        # print(1, cal_day)
        return (self.today - cal_day).days


